/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Goals.Calculations;

import Current.Account;

/**
 * @author Fork
 */
public class DefenseGoals {

    private Integer defenseGoal;
    private Account account;

    public DefenseGoals(Integer defenseGoal, Account account) {
        this.defenseGoal = defenseGoal;
        this.account = account;
    }

    public DefenseGoals(Account account) {
        this.defenseGoal = account.getStats().getDefense();
        this.account = account;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    public Integer getDefenseGoal() {
        return defenseGoal;
    }

    public void setDefenseGoal(Integer defenseGoal) {
        this.defenseGoal = defenseGoal;
    }

    Integer calcNeededFEType1Units() {
        Integer result;
        Integer gap = defenseGoal - account.getStats().getDefense();
        Integer fullyEquipedBoost = account.getUnits().getGuards().getDefenseIncrease() + account.getArmories().getDefArmory().getSetDefenseBonus();

        Double multiplier = 1 + ((double) account.getClassDT().defenseBoost() + account.getRace().defenseBoost() + account.getStructures().getOffFortBonus() + account.getPoints().getConstitution()) / 100;

        result = (int) Math.rint(gap / (multiplier * fullyEquipedBoost));
        return result;
    }

    Integer calcNeededFEType2Units() {
        Integer result;
        Integer gap = defenseGoal - account.getStats().getDefense();
        Integer fullyEquipedBoost = account.getUnits().getArchers().getDefenseIncrease() + account.getArmories().getDefArmory().getSetDefenseBonus() + account.getBattleUpgrades().getDefUpgrades().getDefUpgrades().getDefenseBonus();

        Double multiplier = 1 + ((double) account.getClassDT().defenseBoost() + account.getRace().defenseBoost() + account.getStructures().getOffFortBonus() + account.getPoints().getConstitution()) / 100;

        result = (int) Math.rint(gap / (multiplier * fullyEquipedBoost));
        return result;
    }

    Integer calcNeededFEType3Units() {
        Integer result;
        Integer gap = defenseGoal - account.getStats().getDefense();
        Integer fullyEquipedBoost = account.getUnits().getEliteArchers().getDefenseIncrease() + account.getArmories().getDefArmory().getSetDefenseBonus() + account.getBattleUpgrades().getDefUpgrades().getDefUpgrades().getDefenseBonus();

        Double multiplier = 1 + ((double) account.getClassDT().offenseBoost() + account.getRace().offenseBoost() + account.getStructures().getOffFortBonus() + account.getPoints().getStrength()) / 100;

        result = (int) Math.rint(gap / (multiplier * fullyEquipedBoost));
        return result;
    }

    Integer calcNeededFEType4Units() {
        Integer result;
        Integer gap = defenseGoal - account.getStats().getDefense();
        Integer fullyEquipedBoost = account.getUnits().getRoyalGuards().getDefenseIncrease() + account.getArmories().getDefArmory().getSetDefenseBonus() + account.getBattleUpgrades().getDefUpgrades().getDefUpgrades().getDefenseBonus();

        Double multiplier = 1 + ((double) account.getClassDT().defenseBoost() + account.getRace().defenseBoost() + account.getStructures().getOffFortBonus() + account.getPoints().getConstitution()) / 100;

        result = (int) Math.rint(gap / (multiplier * fullyEquipedBoost));
        return result;
    }

    public Integer calcNeededType1UnitGold() {
        Integer neededUnits = calcNeededFEType1Units();

        Integer costPerFullSetUnit = account.getArmories().getDefArmory().getSetCost() + account.getUnits().getGuards().getCostToTrain();

        return neededUnits * costPerFullSetUnit;
    }

    public Integer calcNeededType2UnitGold() {
        Integer neededUnits = calcNeededFEType2Units();

        Integer costPerFullSetUnit = account.getArmories().getDefArmory().getSetCost() + account.getUnits().getArchers().getCostToTrain();

        return neededUnits * costPerFullSetUnit;
    }

    public Integer calcNeededType3UnitGold() {
        Integer neededUnits = calcNeededFEType3Units();

        Integer costPerFullSetUnit = account.getArmories().getDefArmory().getSetCost() + account.getUnits().getEliteArchers().getCostToTrain();

        return neededUnits * costPerFullSetUnit;
    }

    public Integer calcNeededType4UnitGold() {
        Integer neededUnits = calcNeededFEType4Units();

        Integer costPerFullSetUnit = account.getArmories().getDefArmory().getSetCost() + account.getUnits().getRoyalGuards().getCostToTrain();

        return neededUnits * costPerFullSetUnit;
    }

}
